package com.PQLoad
{
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	public class LoadTime
	{
		private var t:Timer;
		private var func:Function;
		public var delay:int=0;
		private var time:int=0;
		public var totalTime:int=0;
		static public var self:LoadTime=new LoadTime();
		public function LoadTime()
		{
			t=new Timer(10);
		}
		public function add(s:int,callBack:Function):void{
			if(time!=0)return;
			delay=s*1000;
			func=callBack;
			t.addEventListener(TimerEvent.TIMER,run);
			t.start();
			
		}
		public function reset(s:int):void{
			delay=s*1000;
		}
		public function remove():void{
			t.stop();
			t.removeEventListener(TimerEvent.TIMER,run);
			delay=0;
			time=0;
		}
		private function run(e:TimerEvent):void{
			time+=10;
			totalTime+=10;
			if(time<delay)return;
			remove();
			func();
		}
	}
}